import React from 'react';
import { Redirect, Switch, Route } from 'react-router-dom';
import menus from './menus';
import NotFound from '../views/error/NotFound/index';

const redirectMenus = menus.filter((item) => item.redirect);

function RedirectRouterView() {
  return (
    <Switch>
      {redirectMenus.map((item) => {
        const Item = <Redirect key={item.path} exact path={item.path} to={item.redirect} />;
        return Item;
      })}

      <Route component={NotFound} />
    </Switch>
  );
}

export default RedirectRouterView;
